﻿using System;
using System.Web.Optimization;

namespace Pyramid
{
	public class BundleConfig
	{
		public static void RegisterBundles(BundleCollection bundles)
		{
			bundles.IgnoreList.Clear();
			AddDefaultIgnorePatterns(bundles.IgnoreList);

			bundles.Add(new StyleBundle("~/bundles/login/css")
							.Include("~/Content/themes/css/login.css"));

			bundles.Add(new StyleBundle("~/bundles/css/print").Include("~/Content/themes/css/print.css"));

			bundles.Add(new StyleBundle("~/bundles/css/screen")
							.Include("~/Content/themes/azure/style.css",
									"~/Content/themes/css/core.css",
									//"~/Scripts/uploadify/css/uploadify.css",

									/**** kendo ui ****/
									"~/KendoUI/css/kendo.common.css",
									"~/KendoUI/css/kendo.blueopal.css",
									/**** app ****/
									"~/Content/app.css"
							));

			bundles.Add(new StyleBundle("~/bundles/css/iehack").Include("~/Content/themes/css/ieHack.css"));

			bundles.Add(new ScriptBundle("~/bundles/iespeedup").Include("~/Scripts/speedup.js"));

			bundles.Add(new ScriptBundle("~/bundles/dwzframework")
							.Include(
								/**** jquery *****/
								"~/Scripts/jquery-{version}.js",
								"~/Scripts/jquery-migrate-{version}.js",
								"~/Scripts/jquery.cookie.js",
								"~/Scripts/jquery.validate.js",
								"~/Scripts/jquery.bgiframe.js",
								"~/Scripts/jquery.json-{version}.js",
								/***** xheditor *****/
								//"~/Scripts/xheditor/xheditor-{version}-zh-cn.js",
								/***** uploadify *****/
								//"~/Scripts/uploadify/scripts/jquery.uploadify.js",
								/***** chart ******/
								"~/Scripts/chart/raphael.js",
								"~/Scripts/chart/g.raphael.js",
								"~/Scripts/chart/g.bar.js",
								"~/Scripts/chart/g.line.js",
								"~/Scripts/chart/g.pie.js",
								"~/Scripts/chart/g.dot.js",
								/**** dwz ****/
								"~/Scripts/dwz.core.js",
								"~/Scripts/dwz/*.js",
								/**** regional ****/
								"~/Scripts/dwz.regional.zh.js",
								/**** kendo ui ****/
								"~/KendoUI/js/kendo.web.js",
								"~/KendoUI/js/cultures/kendo.culture.zh-CN.js",
								"~/KendoUI/js/cultures/kendo.messages.zh-CN.js",
								/****** main *****/
								"~/Scripts/main.js"
							));
		}

		public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
		{
			if (ignoreList == null)
			{
				throw new ArgumentNullException("ignoreList");
			}

			ignoreList.Ignore("*.intellisense.js");
			ignoreList.Ignore("*-vsdoc.js");
			ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
			ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
			ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
		}
	}

	public class BundlesFormats
	{
		public const string Print = @"<link href=""{0}"" rel=""stylesheet"" type=""text/css"" media=""print"" />";
		public const string IeSpecialStylesheet = @"<!--[if IE]>
			<link href=""{0}"" rel=""stylesheet"" type=""text/css"" media=""screen""/>
		<![endif]-->";
		public const string IeSpecialScript = @"<!--[if lte IE 9]>
			<script src=""{0}"" type=""text/javascript""> </script>
		<![endif]-->";
	}
}